<?php

namespace Home\Model;
use Think\Model;
class CategoryModel extends Model {
    //向上查找父分类
    public  function getPidList($cid)
    {
        $pcat=array();
        while($cid)
        {
            $cat=$this->where("cid=$cid")->find();
            $pcat[]=array(
                'cid'=>$cat['cid'],
                'cname'=>$cat['cname'],
            );
            $cid=$cat['pid'];
            return array_reverse($pcat);
        }
    }
}

